$(document).ready(function(){
	$(".btn_close").on("click", function(event) {
		window.close();
	});
	
	$(".btn_save").on("click", function(event) {		
		url = "insertAccountAdd.jsp";
		serviceName = "ACCOUNT_ADD";
		param = {
				insert_system : $("#insert_system").val(),
				id : $("#id").val(),
				pw : $("#pw").val(),
				pw_check : $("#pw_check").val(),
				group : $("#group").val(),
				login_shell : $("#login_shell").val(),
				home_dir : $("#home_dir").val(),
				used : $("#used").val(),
				used_date : $("#used_date option:selected").val()
		};
		
		callAjax(url,param, serviceName);
	});
	
	
	/* ID 중복체크 */
	$(".btn_overlapchk").on("click", function(event) {
		var url = "checkAccount.jsp";
		var serviceName = "ID_CHECKACCOUNT";
		var param = {
				group_name : $("#group_name").val()
		};
		callAjax(url,param, serviceName);
	});
	
	/* info + 클릭시 */
	$("#group_add").on("click", function(event) {
		var url = "insertGroup.jsp";
		var serviceName = "GROUP_ADD";
		var param = {
				group : $("#group").val(),
				system_type : $("#system_type option:selected").val()
		};
		callAjax(url,param, serviceName);
	});
	/* info - 클릭시 */
	$("#group_del").on("click", function(event) {
		var url = "deleteGroup.jsp";
		var serviceName = "GROUP_DEL";
		var param = {
				group : $("#group").val(),
				system_type : $("#system_type option:selected").val()
		};
		callAjax(url,param, serviceName);
	});
	
});

/* callAjax successAjax */
function successAjax(data, serviceName){
	if(serviceName == "ACCOUNT_ADD"){
		alert(data.result);
	}else if(serviceName == "ID_CHECKACCOUNT"){
		alert(data.result);
	}else if(serviceName == "GROUP_ADD"){
		alert(data.result);
	}else if(serviceName == "GROUP_DEL"){
		alert(data.result);
	}
}